#pragma once

#include "afxwin.h"
#include <string>
#include "CpSysDibEvent.h"
#include "DefineCol.h"

#define STOCK_CODE_INDEX     0
#define REQUEST_TYPE_INDEX     1
#define REQUEST_END_DATE_INDEX    2
#define REQUEST_START_DATE_INDEX   3
#define REQUEST_COUNT_INDEX     4
#define FIELD_LIST_INDEX     5
#define CHART_TYPE_INDEX     6
#define CHART_CYCLE_INDEX     7
#define FIELD_TRANSACTION_COUNT_TYPE_INDEX 10

#define FETCHED_STOCK_CODE_INDEX 0
#define FETCHED_FIELD_COUNT_INDEX 1
#define FETCHED_ROW_COUNT_INDEX  3

#define REQUEST_TYPE_PERIOD '1'
#define REQUEST_TYPE_COUNT '2'

#define FIELD_DATE_INDEX    0
#define FIELD_TIME_INDEX    1
#define FIELD_START_PRICE_INDEX   2
#define FIELD_HIGHEST_PRICE_INDEX  3
#define FIELD_LOWEST_PRICE_INDEX  4
#define FIELD_END_PRICE_INDEX   5
#define FIELD_YESTERDAY_COMPARISON  6
#define FIELD_TRANSACTION_COUNT_INDEX 8
#define FIELD_TRANSACTION_PRICE_INDEX 9
#define FIELD_ACCUMULATED_SELL_QUANTITY 10
#define FIELD_ACCUMULATED_BUY_QUANTITY 11

#define CHART_TYPE_DAY  'D'
#define CHART_TYPE_WEEK  'W'
#define CHART_TYPE_MONTH 'M'
#define CHART_TYPE_MINUTE 'm'
#define CHART_TYPE_TICK  'T'

#define TRANSACTION_COUNT_TYPE_ALL      '1'
#define TRANSACTION_COUNT_TYPE_INCLUDE_AFTER_MARKET  '2'
#define TRANSACTION_COUNT_TYPE_EXCLUDE_AFTER_MARKET  '3'
#define TRANSACTION_COUNT_TYPE_EXCLUDE_BEFORE_MARKET '4'

using namespace std;

class CReceiver;
class CFutOptRcvr :
	public CWnd
{
	DECLARE_DYNAMIC(CFutOptRcvr)
public:
	CReceiver* m_pParent;
	CFutOptRcvr(ChartParam& a_Param);
	CFutOptRcvr();
	~CFutOptRcvr();

	void Unsubscribe();
	void Request();
	void Request(string a_Code, long a_SD, long a_ED, char a_RQType, long a_Count, long a_Period);
	void BlockRequest();
	ChartDataList* BlockRequest(ChartParam& a_Param);
	ChartParam Param;
protected:
	ISysDibPtr      m_FutOptChart;
	CCpSysDibEvent*    m_FutOptChartEvent;

	DECLARE_MESSAGE_MAP()
protected:
	afx_msg LONG OnReceived(WPARAM wParam, LPARAM lParam); // cybos
public:
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};

